﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsMInsertBlockNode : OdGsBlockReferenceNode, OdSiEntity
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsMInsertBlockNode(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsMInsertBlockNode_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsMInsertBlockNode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsMInsertBlockNode()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsMInsertBlockNode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		HandleRef OdSiEntity.GetCPtr()
		{
			return new HandleRef(this, GlobalsPINVOKE.OdGsMInsertBlockNode_OdSiEntity_GetCPtr(this.swigCPtr.Handle));
		}

		public new static OdGsMInsertBlockNode cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMInsertBlockNode_cast(OdRxObject.getCPtr(pObj));
			OdGsMInsertBlockNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMInsertBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMInsertBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMInsertBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMInsertBlockNode_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMInsertBlockNode_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMInsertBlockNode_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsMInsertBlockNode createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMInsertBlockNode_createObject();
			OdGsMInsertBlockNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMInsertBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMInsertBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMInsertBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMInsertBlockNode(OdGsBaseModel pModel, OdGiDrawable pInsert, bool bSetGsNode) : this(GlobalsPINVOKE.new_OdGsMInsertBlockNode__SWIG_0(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pInsert), bSetGsNode), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsMInsertBlockNode(OdGsBaseModel pModel, OdGiDrawable pInsert) : this(GlobalsPINVOKE.new_OdGsMInsertBlockNode__SWIG_1(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pInsert)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void invalidate(OdGsContainerNode pParent, OdGsViewImpl pView, uint mask)
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(pView), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void destroy()
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_destroy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void destroySubitems()
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_destroySubitems(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void highlight(bool bDoIt, bool bWholeBranch)
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_highlight(this.swigCPtr, bDoIt, bWholeBranch);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdGsEntityNode firstEntity()
		{
			OdGsEntityNode result = (OdGsEntityNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMInsertBlockNode_firstEntity(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdGsEntityNode firstAttrib()
		{
			OdGsEntityNode result = (OdGsEntityNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMInsertBlockNode_firstAttrib__SWIG_0(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool layersChanged(OdGsViewImpl view)
		{
			bool result = GlobalsPINVOKE.OdGsMInsertBlockNode_layersChanged(this.swigCPtr, OdGsViewImpl.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void playAsGeometry(OdGsBaseVectorizer view, EMetafilePlayMode eMode)
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_playAsGeometry(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), (int)eMode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void makeStock()
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_makeStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void releaseStock()
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_releaseStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void propagateLayerChangesStock()
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_propagateLayerChangesStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool isMInsert()
		{
			bool result = GlobalsPINVOKE.OdGsMInsertBlockNode_isMInsert(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsEntityNode firstAttrib(uint iInstance)
		{
			OdGsEntityNode result = GlobalsPINVOKE.OdGsMInsertBlockNode_firstAttrib__SWIG_1(this.swigCPtr, iInstance);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void stretchExtents()
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_stretchExtents(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setParams(OdGeMatrix3d blockTf, int nCols, int nRows, double sx, double sy)
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_setParams(this.swigCPtr, OdGeMatrix3d.getCPtr(blockTf), nCols, nRows, sx, sy);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void doDisplay(OdGsDisplayContext ctx)
		{
			GlobalsPINVOKE.OdGsMInsertBlockNode_doDisplay(this.swigCPtr, ctx);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool doSelect(OdGsBaseVectorizer vect, OdGiDrawable pDrw, OdSiRecursiveVisitor pVisitor, OdGsView.SelectionMode mode)
		{
			bool result = GlobalsPINVOKE.OdGsMInsertBlockNode_doSelect(this.swigCPtr, OdGsBaseVectorizer.getCPtr(vect), OdGiDrawable.getCPtr(pDrw), OdSiRecursiveVisitor.getCPtr(pVisitor), (int)mode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
